<!DOCTYPE HTML>
<html lang="en">


<head>
    <meta charset="utf-8">
    <meta name="keywords" content="AverageJoe&#39;s Blog">
    <meta name="description" content="this is my secret garden where I sow my inspirations.">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <!-- Global site tag (gtag.js) - Google Analytics -->


    <title>AverageJoe&#39;s Blog</title>
    <link rel="icon" type="image/png" href="/favicon.png">

    <link rel="stylesheet" type="text/css" href="/libs/awesome/css/all.css">
    <link rel="stylesheet" type="text/css" href="/libs/materialize/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/aos/aos.css">
    <link rel="stylesheet" type="text/css" href="/libs/animate/animate.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/lightGallery/css/lightgallery.min.css">
    <link rel="stylesheet" type="text/css" href="/css/matery.css">
    <link rel="stylesheet" type="text/css" href="/css/my.css">

    <script src="/libs/jquery/jquery.min.js"></script>
<meta name="generator" content="Hexo 5.0.0"><link rel="alternate" href="/atom.xml" title="AverageJoe's Blog" type="application/atom+xml">
</head>


<body>
    <header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="nav-wrapper container">
            <div class="brand-logo">
                <a href="/" class="waves-effect waves-light">
                    
                    <img src="/medias/logo.png" class="logo-img" alt="LOGO">
                    
                    <span class="logo-span">AverageJoe&#39;s Blog</span>
                </a>
            </div>
            

<a href="#" data-target="mobile-nav" class="sidenav-trigger button-collapse"><i class="fas fa-bars"></i></a>
<ul class="right nav-menu">
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/" class="waves-effect waves-light">
      
      <i class="fas fa-home" style="zoom: 0.6;"></i>
      
      <span>Index</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/tags" class="waves-effect waves-light">
      
      <i class="fas fa-tags" style="zoom: 0.6;"></i>
      
      <span>Tags</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/categories" class="waves-effect waves-light">
      
      <i class="fas fa-bookmark" style="zoom: 0.6;"></i>
      
      <span>Categories</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/archives" class="waves-effect waves-light">
      
      <i class="fas fa-archive" style="zoom: 0.6;"></i>
      
      <span>Archives</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/about" class="waves-effect waves-light">
      
      <i class="fas fa-user-circle" style="zoom: 0.6;"></i>
      
      <span>About</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/contact" class="waves-effect waves-light">
      
      <i class="fas fa-comments" style="zoom: 0.6;"></i>
      
      <span>Contact</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/friends" class="waves-effect waves-light">
      
      <i class="fas fa-address-book" style="zoom: 0.6;"></i>
      
      <span>Friends</span>
    </a>
    
  </li>
  
  <li>
    <a href="#searchModal" class="modal-trigger waves-effect waves-light">
      <i id="searchIcon" class="fas fa-search" title="Search" style="zoom: 0.85;"></i>
    </a>
  </li>
</ul>


<div id="mobile-nav" class="side-nav sidenav">

    <div class="mobile-head bg-color">
        
        <img src="/medias/logo.png" class="logo-img circle responsive-img">
        
        <div class="logo-name">AverageJoe&#39;s Blog</div>
        <div class="logo-desc">
            
            this is my secret garden where I sow my inspirations.
            
        </div>
    </div>

    

    <ul class="menu-list mobile-menu-list">
        
        <li class="m-nav-item">
	  
		<a href="/" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-home"></i>
			
			Index
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/tags" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-tags"></i>
			
			Tags
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/categories" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-bookmark"></i>
			
			Categories
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/archives" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-archive"></i>
			
			Archives
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/about" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-user-circle"></i>
			
			About
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/contact" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-comments"></i>
			
			Contact
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/friends" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-address-book"></i>
			
			Friends
		</a>
          
        </li>
        
        
    </ul>
</div>


        </div>

        
    </nav>

</header>

    
<script src="/libs/cryptojs/crypto-js.min.js"></script>
<script>
    (function() {
        let pwd = '';
        if (pwd && pwd.length > 0) {
            if (pwd !== CryptoJS.SHA256(prompt('请输入访问本文章的密码')).toString(CryptoJS.enc.Hex)) {
                alert('密码错误，将返回主页！');
                location.href = '/';
            }
        }
    })();
</script>




<div class="bg-cover pd-header post-cover" style="background-image: url('/medias/featureimages/0.jpg')">
    <div class="container" style="right: 0px;left: 0px;">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <h1 class="description center-align post-title"></h1>
                </div>
            </div>
        </div>
    </div>
</div>




<main class="post-container content">

    
    <link rel="stylesheet" href="/libs/tocbot/tocbot.css">
<style>
    #articleContent h1::before,
    #articleContent h2::before,
    #articleContent h3::before,
    #articleContent h4::before,
    #articleContent h5::before,
    #articleContent h6::before {
        display: block;
        content: " ";
        height: 100px;
        margin-top: -100px;
        visibility: hidden;
    }

    #articleContent :focus {
        outline: none;
    }

    .toc-fixed {
        position: fixed;
        top: 64px;
    }

    .toc-widget {
        width: 345px;
        padding-left: 20px;
    }

    .toc-widget .toc-title {
        margin: 35px 0 15px 0;
        padding-left: 17px;
        font-size: 1.5rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    .toc-widget ol {
        padding: 0;
        list-style: none;
    }

    #toc-content {
        height: calc(100vh - 250px);
        overflow: auto;
    }

    #toc-content ol {
        padding-left: 10px;
    }

    #toc-content ol li {
        padding-left: 10px;
    }

    #toc-content .toc-link:hover {
        color: #42b983;
        font-weight: 700;
        text-decoration: underline;
    }

    #toc-content .toc-link::before {
        background-color: transparent;
        max-height: 25px;

        position: absolute;
        right: 23.5vw;
        display: block;
    }

    #toc-content .is-active-link {
        color: #42b983;
    }

    #floating-toc-btn {
        position: fixed;
        right: 15px;
        bottom: 76px;
        padding-top: 15px;
        margin-bottom: 0;
        z-index: 998;
    }

    #floating-toc-btn .btn-floating {
        width: 48px;
        height: 48px;
    }

    #floating-toc-btn .btn-floating i {
        line-height: 48px;
        font-size: 1.4rem;
    }
</style>
<div class="row">
    <div id="main-content" class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            <div class="row tag-cate">
                <div class="col s7">
                    
                          <div class="article-tag">
                            <span class="chip bg-color">No tag</span>
                          </div>
                    
                </div>
                <div class="col s5 right-align">
                    
                </div>
            </div>

            <div class="post-info">
                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-minus fa-fw"></i>Publish Date:&nbsp;&nbsp;
                    2018-10-08
                </div>
                

                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-check fa-fw"></i>Update Date:&nbsp;&nbsp;
                    2018-10-08
                </div>
                

                
                <div class="info-break-policy">
                    <i class="far fa-file-word fa-fw"></i>Word Count:&nbsp;&nbsp;
                    4.9k
                </div>
                

                
                <div class="info-break-policy">
                    <i class="far fa-clock fa-fw"></i>Read Times:&nbsp;&nbsp;
                    21 Min
                </div>
                

                
                    <div id="busuanzi_container_page_pv" class="info-break-policy">
                        <i class="far fa-eye fa-fw"></i>Read Count:&nbsp;&nbsp;
                        <span id="busuanzi_value_page_pv"></span>
                    </div>
				
            </div>
        </div>
        <hr class="clearfix">
        <div class="card-content article-card-content">
            <div id="articleContent">
                <h1 id="0-学习目标"><a href="#0-学习目标" class="headerlink" title="0.学习目标"></a>0.学习目标</h1><ul>
<li>独立实现商品新增后台</li>
<li>独立实现商品编辑后台</li>
<li>独立搭建前台系统页面</li>
</ul>
<h1 id="1-商品新增"><a href="#1-商品新增" class="headerlink" title="1.商品新增"></a>1.商品新增</h1><p>当我们点击新增商品按钮：</p>
<p><img src="assets/1528450695946.png" alt="1528450695946"></p>
<p>就会出现一个弹窗：</p>
<p><img src="assets/1528450773322.png" alt="1528450773322"></p>
<p>里面把商品的数据分为了4部分来填写：</p>
<ul>
<li>基本信息：主要是一些简单的文本数据，包含了SPU和SpuDetail的部分数据，如<ul>
<li>商品分类：是SPU中的<code>cid1</code>，<code>cid2</code>，<code>cid3</code>属性</li>
<li>品牌：是spu中的<code>brandId</code>属性</li>
<li>标题：是spu中的<code>title</code>属性</li>
<li>子标题：是spu中的<code>subTitle</code>属性</li>
<li>售后服务：是SpuDetail中的<code>afterService</code>属性</li>
<li>包装列表：是SpuDetail中的<code>packingList</code>属性</li>
</ul>
</li>
<li>商品描述：是SpuDetail中的<code>description</code>属性，数据较多，所以单独放一个页面</li>
<li>规格参数：商品规格信息，对应SpuDetail中的<code>genericSpec</code>属性</li>
<li>SKU属性：spu下的所有Sku信息</li>
</ul>
<p>对应到页面中的四个<code>stepper-content</code>：</p>
<p><img src="assets/1528457410198.png" alt="1528457410198"></p>
<h2 id="1-1-弹窗事件"><a href="#1-1-弹窗事件" class="headerlink" title="1.1.弹窗事件"></a>1.1.弹窗事件</h2><p>弹窗是一个独立组件：</p>
<p> <img src="assets/1528084394245.png" alt="1528084394245"></p>
<p>并且在Goods组件中已经引用它：</p>
<p><img src="assets/1528457758806.png" alt="1528457758806"></p>
<p>并且在页面中渲染：</p>
<p><img src="assets/1528457859739.png" alt="1528457859739"></p>
<p>在<code>新增商品</code>按钮的点击事件中，改变这个<code>dialog</code>的<code>show</code>属性：</p>
<p><img src="assets/1528457992959.png" alt="1528457992959"></p>
<p><img src="assets/1528458037693.png" alt="1528458037693"></p>
<h2 id="1-2-基本数据"><a href="#1-2-基本数据" class="headerlink" title="1.2.基本数据"></a>1.2.基本数据</h2><p>我们先来看下基本数据：</p>
<p><img src="H:/%E4%B9%90%E4%BC%98/7%E6%9C%881%E5%8F%B7%E6%9B%B4%E6%96%B0/day10-%E5%95%86%E5%93%81%E7%AE%A1%E7%90%86/assets/1528086595597.png" alt="1528086595597"></p>
<h3 id="1-2-1-商品分类"><a href="#1-2-1-商品分类" class="headerlink" title="1.2.1.商品分类"></a>1.2.1.商品分类</h3><p>商品分类信息查询我们之前已经做过，所以这里的级联选框已经实现完成：</p>
<p><img src="assets/1528459846644.png" alt="1528459846644"></p>
<p>刷新页面，可以看到请求已经发出：</p>
<p><img src="assets/1528460001803.png" alt="1528460001803"></p>
<p><img src="assets/1528460054188.png" alt="1528460054188"></p>
<p>效果：</p>
<p><img src="assets/1528460159541.png" alt="1528460159541"></p>
<h3 id="1-2-2-品牌选择"><a href="#1-2-2-品牌选择" class="headerlink" title="1.2.2.品牌选择"></a>1.2.2.品牌选择</h3><h4 id="1-2-2-1页面"><a href="#1-2-2-1页面" class="headerlink" title="1.2.2.1页面"></a>1.2.2.1页面</h4><p>品牌也是一个下拉选框，不过其选项是不确定的，只有当用户选择了商品分类，才会把这个分类下的所有品牌展示出来。</p>
<p>所以页面编写了watch函数，监控商品分类的变化，每当商品分类值有变化，就会发起请求，查询品牌列表：</p>
<p><img src="assets/1528460401582.png" alt="1528460401582"></p>
<p>选择商品分类后，可以看到请求发起：</p>
<p><img src="assets/1528460607735.png" alt="1528460607735"></p>
<p>接下来，我们只要编写后台接口，根据商品分类id，查询对应品牌即可。</p>
<h4 id="1-2-2-2后台接口"><a href="#1-2-2-2后台接口" class="headerlink" title="1.2.2.2后台接口"></a>1.2.2.2后台接口</h4><p>页面需要去后台查询品牌信息，我们自然需要提供：</p>
<p>请求方式：GET</p>
<p>请求路径：/brand/cid/{cid}</p>
<p>请求参数：cid</p>
<p>响应数据：品牌集合</p>
<blockquote>
<p>BrandController</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment">     * 根据分类查询品牌</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@param</span> cid</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@return</span></span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line"><span class="meta">@GetMapping(&quot;cid/&#123;cid&#125;&quot;)</span></span><br><span class="line"><span class="keyword">public</span> ResponseEntity&lt;List&lt;Brand&gt;&gt; queryBrandListByCid(<span class="meta">@PathVariable(&quot;cid&quot;)</span>Long cid)&#123;</span><br><span class="line"></span><br><span class="line">    List&lt;Brand&gt; brandList = <span class="keyword">this</span>.brandService.queryByCid(cid);</span><br><span class="line">    <span class="keyword">if</span>(CollectionUtils.isEmpty(brandList))&#123;</span><br><span class="line">        <span class="comment">// 响应404</span></span><br><span class="line">        <span class="keyword">return</span> ResponseEntity.badRequest().build();</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">// 响应200</span></span><br><span class="line">    <span class="keyword">return</span> ResponseEntity.ok(brandList);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<blockquote>
<p>BrandService</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">public</span> List&lt;Brand&gt; <span class="title">queryBrandByCategory</span><span class="params">(Long cid)</span> </span>&#123;</span><br><span class="line">    <span class="keyword">return</span> <span class="keyword">this</span>.brandMapper.queryByCategoryId(cid);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>



<blockquote>
<p>BrandMapper</p>
</blockquote>
<p>根据分类查询品牌有中间表，需要自己编写Sql：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@Select(&quot;SELECT b.* FROM tb_brand b LEFT JOIN tb_category_brand cb ON b.id = cb.brand_id WHERE cb.category_id = #&#123;cid&#125;&quot;)</span></span><br><span class="line"><span class="function">List&lt;Brand&gt; <span class="title">queryByCategoryId</span><span class="params">(Long cid)</span></span>;</span><br></pre></td></tr></table></figure>



<p>效果：</p>
<p><img src="assets/1528462393536.png" alt="1528462393536"></p>
<h3 id="1-2-3-其它文本框"><a href="#1-2-3-其它文本框" class="headerlink" title="1.2.3.其它文本框"></a>1.2.3.其它文本框</h3><p>剩余的几个属性：标题、子标题等都是普通文本框，我们直接填写即可，没有需要特别注意的。</p>
<p><img src="assets/1528462474512.png" alt="1528462474512"></p>
<h2 id="1-3-商品描述"><a href="#1-3-商品描述" class="headerlink" title="1.3.商品描述"></a>1.3.商品描述</h2><p>商品描述信息比较复杂，而且图文并茂，甚至包括视频。</p>
<p>这样的内容，一般都会使用富文本编辑器。</p>
<h3 id="1-3-1-什么是富文本编辑器"><a href="#1-3-1-什么是富文本编辑器" class="headerlink" title="1.3.1.什么是富文本编辑器"></a>1.3.1.什么是富文本编辑器</h3><p>百度百科：</p>
<p><img src="assets/1526290914491.png" alt="1526290914491"></p>
<p>通俗来说：富文本，就是比较丰富的文本编辑器。普通的框只能输入文字，而富文本还能给文字加颜色样式等。</p>
<p>富文本编辑器有很多，例如：KindEditor、Ueditor。但并不原生支持vue</p>
<p>但是我们今天要说的，是一款支持Vue的富文本编辑器：<code>vue-quill-editor</code></p>
<h3 id="1-3-2-Vue-Quill-Editor"><a href="#1-3-2-Vue-Quill-Editor" class="headerlink" title="1.3.2.Vue-Quill-Editor"></a>1.3.2.Vue-Quill-Editor</h3><p>GitHub的主页：<a target="_blank" rel="noopener" href="https://github.com/surmon-china/vue-quill-editor">https://github.com/surmon-china/vue-quill-editor</a></p>
<p>Vue-Quill-Editor是一个基于Quill的富文本编辑器：<a target="_blank" rel="noopener" href="https://quilljs.com/">Quill的官网</a></p>
<p><img src="assets/1526291232678.png" alt="1526291232678"></p>
<h3 id="1-3-3-使用指南"><a href="#1-3-3-使用指南" class="headerlink" title="1.3.3.使用指南"></a>1.3.3.使用指南</h3><p>使用非常简单：</p>
<p>第一步：安装，使用npm命令：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm install vue-quill-editor --save</span><br></pre></td></tr></table></figure>

<p>第二步：加载，在js中引入：</p>
<p>全局引入：</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> Vue <span class="keyword">from</span> <span class="string">&#x27;vue&#x27;</span></span><br><span class="line"><span class="keyword">import</span> VueQuillEditor <span class="keyword">from</span> <span class="string">&#x27;vue-quill-editor&#x27;</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">const</span> options = &#123;&#125;; <span class="comment">/* &#123; default global options &#125; */</span></span><br><span class="line"></span><br><span class="line">Vue.use(VueQuillEditor, options); <span class="comment">// options可选</span></span><br></pre></td></tr></table></figure>



<p>局部引入：</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> <span class="string">&#x27;quill/dist/quill.core.css&#x27;</span></span><br><span class="line"><span class="keyword">import</span> <span class="string">&#x27;quill/dist/quill.snow.css&#x27;</span></span><br><span class="line"><span class="keyword">import</span> <span class="string">&#x27;quill/dist/quill.bubble.css&#x27;</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> &#123;quillEditor&#125; <span class="keyword">from</span> <span class="string">&#x27;vue-quill-editor&#x27;</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">var</span> vm = <span class="keyword">new</span> Vue(&#123;</span><br><span class="line">    components:&#123;</span><br><span class="line">        quillEditor</span><br><span class="line">    &#125;</span><br><span class="line">&#125;)</span><br></pre></td></tr></table></figure>



<p>我们这里采用局部引用：</p>
<p><img src="assets/1528465859061.png" alt="1528465859061"></p>
<p>第三步：页面使用：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">quill-editor</span> <span class="attr">v-model</span>=<span class="string">&quot;goods.spuDetail.description&quot;</span> <span class="attr">:options</span>=<span class="string">&quot;editorOption&quot;</span>/&gt;</span></span><br></pre></td></tr></table></figure>



<h3 id="1-3-4-自定义的富文本编辑器"><a href="#1-3-4-自定义的富文本编辑器" class="headerlink" title="1.3.4.自定义的富文本编辑器"></a>1.3.4.自定义的富文本编辑器</h3><p>不过这个组件有个小问题，就是图片上传的无法直接上传到后台，因此我们对其进行了封装，支持了图片的上传。</p>
<p> <img src="assets/1526296083605.png" alt="1526296083605.png"></p>
<p>使用也非常简单：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">v-stepper-content</span> <span class="attr">step</span>=<span class="string">&quot;2&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">v-editor</span> <span class="attr">v-model</span>=<span class="string">&quot;goods.spuDetail.description&quot;</span> <span class="attr">upload-url</span>=<span class="string">&quot;/upload/image&quot;</span>/&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">v-stepper-content</span>&gt;</span></span><br></pre></td></tr></table></figure>

<ul>
<li>upload-url：是图片上传的路径</li>
<li>v-model：双向绑定，将富文本编辑器的内容绑定到goods.spuDetail.description</li>
</ul>
<h3 id="1-3-5-效果"><a href="#1-3-5-效果" class="headerlink" title="1.3.5.效果"></a>1.3.5.效果</h3><p><img src="assets/1528469209005.png" alt="1528469209005"></p>
<h2 id="1-4-商品规格参数"><a href="#1-4-商品规格参数" class="headerlink" title="1.4.商品规格参数"></a>1.4.商品规格参数</h2><p>规格参数的查询我们之前也已经编写过接口，因为商品规格参数也是与商品分类绑定，所以需要在商品分类变化后去查询，我们也是通过watch监控来实现：</p>
<p><img src="assets/1528469560330.png" alt="1528469560330"></p>
<p>可以看到这里是根据商品分类id查询规格参数：SpecParam。我们之前写过一个根据gid（分组id）来查询规格参数的接口，我们接下来完成根据分类id查询规格参数。</p>
<blockquote>
<h3 id="改造查询规格参数接口"><a href="#改造查询规格参数接口" class="headerlink" title="改造查询规格参数接口"></a>改造查询规格参数接口</h3></blockquote>
<p>我们在原来的根据 gid（规格组id)查询规格参数的接口上，添加一个参数：cid，即商品分类id。</p>
<p>等一下， 考虑到以后可能还会根据是否搜索、是否为通用属性等条件过滤，我们多添加几个过滤条件：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@GetMapping(&quot;/params&quot;)</span></span><br><span class="line"><span class="keyword">public</span> ResponseEntity&lt;List&lt;SpecParam&gt;&gt; querySpecParam(</span><br><span class="line">    <span class="meta">@RequestParam(value=&quot;gid&quot;, required = false)</span> Long gid,</span><br><span class="line">    <span class="meta">@RequestParam(value=&quot;cid&quot;, required = false)</span> Long cid,</span><br><span class="line">    <span class="meta">@RequestParam(value=&quot;searching&quot;, required = false)</span> Boolean searching,</span><br><span class="line">    <span class="meta">@RequestParam(value=&quot;generic&quot;, required = false)</span> Boolean generic</span><br><span class="line">    )&#123;</span><br><span class="line">        List&lt;SpecParam&gt; list =</span><br><span class="line">                <span class="keyword">this</span>.specificationService.querySpecParams(gid,cid,searching,generic);</span><br><span class="line">        <span class="keyword">if</span>(list == <span class="keyword">null</span> || list.size() == <span class="number">0</span>)&#123;</span><br><span class="line">            <span class="keyword">return</span> <span class="keyword">new</span> ResponseEntity&lt;&gt;(HttpStatus.NOT_FOUND);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">return</span> ResponseEntity.ok(list);</span><br><span class="line">    &#125;</span><br></pre></td></tr></table></figure>

<p>改造service：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">public</span> List&lt;SpecParam&gt; <span class="title">querySpecParams</span><span class="params">(Long gid, Long cid, Boolean searching, Boolean generic)</span> </span>&#123;</span><br><span class="line">    SpecParam param = <span class="keyword">new</span> SpecParam();</span><br><span class="line">    param.setGroupId(gid);</span><br><span class="line">    param.setCid(cid);</span><br><span class="line">    param.setSearching(searching);</span><br><span class="line">    param.setGeneric(generic);</span><br><span class="line">    <span class="keyword">return</span> <span class="keyword">this</span>.specParamMapper.select(param);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>如果param中有属性为null，则不会吧属性作为查询条件，因此该方法具备通用性，即可根据gid查询，也可根据cid查询。</p>
<p>测试：</p>
<p><img src="assets/1528470181643.png" alt="1528470181643"></p>
<p>刷新页面测试：</p>
<p><img src="assets/1528470221970.png" alt="1528470221970"></p>
<h2 id="1-5-SKU信息"><a href="#1-5-SKU信息" class="headerlink" title="1.5.SKU信息"></a>1.5.SKU信息</h2><p>Sku属性是SPU下的每个商品的不同特征，如图：</p>
<p><img src="assets/1528470828296.png" alt="1528470828296"></p>
<p>当我们填写一些属性后，会在页面下方生成一个sku表格，大家可以计算下会生成多少个不同属性的Sku呢？</p>
<p>当你选择了上图中的这些选项时：</p>
<ul>
<li>颜色共2种：迷夜黑，勃艮第红，绚丽蓝</li>
<li>内存共2种：4GB，6GB</li>
<li>机身存储1种：64GB，128GB</li>
</ul>
<p>此时会产生多少种SKU呢？ 应该是 3 * 2 * 2 = 12种，这其实就是在求笛卡尔积。</p>
<p>我们会在页面下方生成一个sku的表格：</p>
<p><img src="assets/1528470876872.png" alt="1528470876872"></p>
<h2 id="1-6-页面表单提交"><a href="#1-6-页面表单提交" class="headerlink" title="1.6.页面表单提交"></a>1.6.页面表单提交</h2><p>在sku列表的下方，有一个提交按钮：</p>
<p><img src="assets/1528470945475.png" alt="1528470945475"></p>
<p>并且绑定了点击事件：</p>
<p><img src="assets/1528471079383.png" alt="1528471079383"></p>
<p>点击后会组织数据并向后台提交：</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br></pre></td><td class="code"><pre><span class="line">submit() &#123;</span><br><span class="line">  <span class="comment">// 表单校验。</span></span><br><span class="line">  <span class="keyword">if</span>(!<span class="built_in">this</span>.$refs.basic.validate)&#123;</span><br><span class="line">    <span class="built_in">this</span>.$message.error(<span class="string">&quot;请先完成表单内容！&quot;</span>);</span><br><span class="line">  &#125;</span><br><span class="line">  <span class="comment">// 先处理goods，用结构表达式接收,除了categories外，都接收到goodsParams中</span></span><br><span class="line">  <span class="keyword">const</span> &#123;</span><br><span class="line">    categories: [&#123; <span class="attr">id</span>: cid1 &#125;, &#123; <span class="attr">id</span>: cid2 &#125;, &#123; <span class="attr">id</span>: cid3 &#125;],</span><br><span class="line">    ...goodsParams</span><br><span class="line">  &#125; = <span class="built_in">this</span>.goods;</span><br><span class="line">  <span class="comment">// 处理规格参数</span></span><br><span class="line">  <span class="keyword">const</span> specs = &#123;&#125;;</span><br><span class="line">  <span class="built_in">this</span>.specs.forEach(<span class="function">(<span class="params">&#123; id,v &#125;</span>) =&gt;</span> &#123;</span><br><span class="line">    specs[id] = v;</span><br><span class="line">  &#125;);</span><br><span class="line">  <span class="comment">// 处理特有规格参数模板</span></span><br><span class="line">  <span class="keyword">const</span> specTemplate = &#123;&#125;;</span><br><span class="line">  <span class="built_in">this</span>.specialSpecs.forEach(<span class="function">(<span class="params">&#123; id, options &#125;</span>) =&gt;</span> &#123;</span><br><span class="line">    specTemplate[id] = options;</span><br><span class="line">  &#125;);</span><br><span class="line">  <span class="comment">// 处理sku</span></span><br><span class="line">  <span class="keyword">const</span> skus = <span class="built_in">this</span>.skus</span><br><span class="line">    .filter(<span class="function"><span class="params">s</span> =&gt;</span> s.enable)</span><br><span class="line">    .map(<span class="function">(<span class="params">&#123; price, stock, enable, images, indexes, ...rest &#125;</span>) =&gt;</span> &#123;</span><br><span class="line">      <span class="comment">// 标题，在spu的title基础上，拼接特有规格属性值</span></span><br><span class="line">      <span class="keyword">const</span> title = goodsParams.title + <span class="string">&quot; &quot;</span> + <span class="built_in">Object</span>.values(rest).map(<span class="function"><span class="params">v</span> =&gt;</span> v.v).join(<span class="string">&quot; &quot;</span>);</span><br><span class="line">      <span class="keyword">const</span> obj = &#123;&#125;;</span><br><span class="line">      <span class="built_in">Object</span>.values(rest).forEach(<span class="function"><span class="params">v</span> =&gt;</span> &#123;</span><br><span class="line">        obj[v.id] = v.v;</span><br><span class="line">      &#125;);</span><br><span class="line">      <span class="keyword">return</span> &#123;</span><br><span class="line">        price: <span class="built_in">this</span>.$format(price), <span class="comment">// 价格需要格式化</span></span><br><span class="line">        stock,</span><br><span class="line">        indexes,</span><br><span class="line">        enable,</span><br><span class="line">        title, <span class="comment">// 基本属性</span></span><br><span class="line">        images: images ? images.join(<span class="string">&quot;,&quot;</span>) : <span class="string">&#x27;&#x27;</span>, <span class="comment">// 图片</span></span><br><span class="line">        ownSpec: <span class="built_in">JSON</span>.stringify(obj) <span class="comment">// 特有规格参数</span></span><br><span class="line">      &#125;;</span><br><span class="line">    &#125;);</span><br><span class="line">  <span class="built_in">Object</span>.assign(goodsParams, &#123;</span><br><span class="line">    cid1,</span><br><span class="line">    cid2,</span><br><span class="line">    cid3, <span class="comment">// 商品分类</span></span><br><span class="line">    skus <span class="comment">// sku列表</span></span><br><span class="line">  &#125;);</span><br><span class="line">  goodsParams.spuDetail.genericSpec = <span class="built_in">JSON</span>.stringify(specs);</span><br><span class="line">  goodsParams.spuDetail.specialSpec = <span class="built_in">JSON</span>.stringify(specTemplate);</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 提交到后台</span></span><br><span class="line">  <span class="built_in">this</span>.$http(&#123;</span><br><span class="line">    method: <span class="built_in">this</span>.isEdit ? <span class="string">&quot;put&quot;</span> : <span class="string">&quot;post&quot;</span>,</span><br><span class="line">    url: <span class="string">&quot;/item/goods&quot;</span>,</span><br><span class="line">    data: goodsParams</span><br><span class="line">  &#125;)</span><br><span class="line">    .then(<span class="function">() =&gt;</span> &#123;</span><br><span class="line">      <span class="comment">// 成功，关闭窗口</span></span><br><span class="line">      <span class="built_in">this</span>.$emit(<span class="string">&quot;close&quot;</span>);</span><br><span class="line">      <span class="comment">// 提示成功</span></span><br><span class="line">      <span class="built_in">this</span>.$message.success(<span class="string">&quot;保存成功了&quot;</span>);</span><br><span class="line">    &#125;)</span><br><span class="line">    .catch(<span class="function">() =&gt;</span> &#123;</span><br><span class="line">      <span class="built_in">this</span>.$message.error(<span class="string">&quot;保存失败！&quot;</span>);</span><br><span class="line">    &#125;);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>



<p>点击提交，查看控制台提交的数据格式：</p>
<p><img src="assets/1528472289831.png" alt="1528472289831"></p>
<p>整体是一个json格式数据，包含Spu表所有数据：</p>
<ul>
<li>brandId：品牌id</li>
<li>cid1、cid2、cid3：商品分类id</li>
<li>subTitle：副标题</li>
<li>title：标题</li>
<li>spuDetail：是一个json对象，代表商品详情表数据<ul>
<li>afterService：售后服务</li>
<li>description：商品描述</li>
<li>packingList：包装列表</li>
<li>specialSpec：sku规格属性模板</li>
<li>genericSpec：通用规格参数</li>
</ul>
</li>
<li>skus：spu下的所有sku数组，元素是每个sku对象：<ul>
<li>title：标题</li>
<li>images：图片</li>
<li>price：价格</li>
<li>stock：库存</li>
<li>ownSpec：特有规格参数</li>
<li>indexes：特有规格参数的下标</li>
</ul>
</li>
</ul>
<h2 id="1-7-后台实现"><a href="#1-7-后台实现" class="headerlink" title="1.7.后台实现"></a>1.7.后台实现</h2><h3 id="1-7-1-实体类"><a href="#1-7-1-实体类" class="headerlink" title="1.7.1.实体类"></a>1.7.1.实体类</h3><p>SPU和SpuDetail实体类已经添加过，添加Sku和Stock对象：</p>
<p> <img src="assets/1528472531490.png" alt="1528472531490"></p>
<blockquote>
<p>Sku</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@Table(name = &quot;tb_sku&quot;)</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Sku</span> </span>&#123;</span><br><span class="line">    <span class="meta">@Id</span></span><br><span class="line">    <span class="meta">@GeneratedValue(strategy = GenerationType.IDENTITY)</span></span><br><span class="line">    <span class="keyword">private</span> Long id;</span><br><span class="line">    <span class="keyword">private</span> Long spuId;</span><br><span class="line">    <span class="keyword">private</span> String title;</span><br><span class="line">    <span class="keyword">private</span> String images;</span><br><span class="line">    <span class="keyword">private</span> Long price;</span><br><span class="line">    <span class="keyword">private</span> String ownSpec;<span class="comment">// 商品特殊规格的键值对</span></span><br><span class="line">    <span class="keyword">private</span> String indexes;<span class="comment">// 商品特殊规格的下标</span></span><br><span class="line">    <span class="keyword">private</span> Boolean enable;<span class="comment">// 是否有效，逻辑删除用</span></span><br><span class="line">    <span class="keyword">private</span> Date createTime;<span class="comment">// 创建时间</span></span><br><span class="line">    <span class="keyword">private</span> Date lastUpdateTime;<span class="comment">// 最后修改时间</span></span><br><span class="line">    <span class="meta">@Transient</span></span><br><span class="line">    <span class="keyword">private</span> Integer stock;<span class="comment">// 库存</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>注意：这里保存了一个库存字段，在数据库中是另外一张表保存的，方便查询。</p>
<blockquote>
<p>Stock</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@Table(name = &quot;tb_stock&quot;)</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Stock</span> </span>&#123;</span><br><span class="line">    <span class="meta">@Id</span></span><br><span class="line">    <span class="keyword">private</span> Long skuId;</span><br><span class="line">    <span class="keyword">private</span> Integer seckillStock;<span class="comment">// 秒杀可用库存</span></span><br><span class="line">    <span class="keyword">private</span> Integer seckillTotal;<span class="comment">// 已秒杀数量</span></span><br><span class="line">    <span class="keyword">private</span> Integer stock;<span class="comment">// 正常库存</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>



<h3 id="1-7-2-GoodsController"><a href="#1-7-2-GoodsController" class="headerlink" title="1.7.2.GoodsController"></a>1.7.2.GoodsController</h3><p>请求方式：POST</p>
<p>请求路径：/goods</p>
<p>请求参数：Spu的json格式的对象，spu中包含spuDetail和Sku集合。这里我们该怎么接收？我们之前定义了一个SpuBo对象，作为业务对象。这里也可以用它，不过需要再扩展spuDetail和skus字段：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">SpuBo</span> <span class="keyword">extends</span> <span class="title">Spu</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@Transient</span></span><br><span class="line">    String cname;<span class="comment">// 商品分类名称</span></span><br><span class="line">    <span class="meta">@Transient</span></span><br><span class="line">    String bname;<span class="comment">// 品牌名称</span></span><br><span class="line">    <span class="meta">@Transient</span></span><br><span class="line">    SpuDetail spuDetail;<span class="comment">// 商品详情</span></span><br><span class="line">    <span class="meta">@Transient</span></span><br><span class="line">    List&lt;Sku&gt; skus;<span class="comment">// sku列表</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<ul>
<li>返回类型：无</li>
</ul>
<p>代码：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 新增商品</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> spu</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@return</span></span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="meta">@PostMapping</span></span><br><span class="line"><span class="function"><span class="keyword">public</span> ResponseEntity&lt;Void&gt; <span class="title">saveGoods</span><span class="params">(<span class="meta">@RequestBody</span> SpuBo spuBo)</span> </span>&#123;</span><br><span class="line">    <span class="keyword">try</span> &#123;</span><br><span class="line">        <span class="keyword">this</span>.goodsService.save(spu);</span><br><span class="line">        <span class="keyword">return</span> <span class="keyword">new</span> ResponseEntity&lt;&gt;(HttpStatus.CREATED);</span><br><span class="line">    &#125; <span class="keyword">catch</span> (Exception e) &#123;</span><br><span class="line">        e.printStackTrace();</span><br><span class="line">        <span class="keyword">return</span> <span class="keyword">new</span> ResponseEntity&lt;&gt;(HttpStatus.INTERNAL_SERVER_ERROR);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>注意：通过@RequestBody注解来接收Json请求</p>
<h3 id="1-7-3-GoodsService"><a href="#1-7-3-GoodsService" class="headerlink" title="1.7.3.GoodsService"></a>1.7.3.GoodsService</h3><p>这里的逻辑比较复杂，我们除了要对SPU新增以外，还要对SpuDetail、Sku、Stock进行保存</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@Transactional</span></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">save</span><span class="params">(SpuBo spu)</span> </span>&#123;</span><br><span class="line">    <span class="comment">// 保存spu</span></span><br><span class="line">    spu.setSaleable(<span class="keyword">true</span>);</span><br><span class="line">    spu.setValid(<span class="keyword">true</span>);</span><br><span class="line">    spu.setCreateTime(<span class="keyword">new</span> Date());</span><br><span class="line">    spu.setLastUpdateTime(spu.getCreateTime());</span><br><span class="line">    <span class="keyword">this</span>.spuMapper.insert(spu);</span><br><span class="line">    <span class="comment">// 保存spu详情</span></span><br><span class="line">    spu.getSpuDetail().setSpuId(spu.getId());</span><br><span class="line">    <span class="keyword">this</span>.spuDetailMapper.insert(spu.getSpuDetail());</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 保存sku和库存信息</span></span><br><span class="line">    saveSkuAndStock(spu.getSkus(), spu.getId());</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">private</span> <span class="keyword">void</span> <span class="title">saveSkuAndStock</span><span class="params">(List&lt;Sku&gt; skus, Long spuId)</span> </span>&#123;</span><br><span class="line">    <span class="keyword">for</span> (Sku sku : skus) &#123;</span><br><span class="line">        <span class="keyword">if</span> (!sku.getEnable()) &#123;</span><br><span class="line">            <span class="keyword">continue</span>;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="comment">// 保存sku</span></span><br><span class="line">        sku.setSpuId(spuId);</span><br><span class="line">        <span class="comment">// 初始化时间</span></span><br><span class="line">        sku.setCreateTime(<span class="keyword">new</span> Date());</span><br><span class="line">        sku.setLastUpdateTime(sku.getCreateTime());</span><br><span class="line">        <span class="keyword">this</span>.skuMapper.insert(sku);</span><br><span class="line"></span><br><span class="line">        <span class="comment">// 保存库存信息</span></span><br><span class="line">        Stock stock = <span class="keyword">new</span> Stock();</span><br><span class="line">        stock.setSkuId(sku.getId());</span><br><span class="line">        stock.setStock(sku.getStock());</span><br><span class="line">        <span class="keyword">this</span>.stockMapper.insert(stock);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>



<h3 id="1-7-4-Mapper"><a href="#1-7-4-Mapper" class="headerlink" title="1.7.4.Mapper"></a>1.7.4.Mapper</h3><p>都是通用Mapper，略</p>
<p>目录结构：</p>
<p> <img src="assets/1528473533815.png" alt="1528473533815"></p>
<h1 id="2-商品修改"><a href="#2-商品修改" class="headerlink" title="2.商品修改"></a>2.商品修改</h1><h2 id="2-1-编辑按钮点击事件"><a href="#2-1-编辑按钮点击事件" class="headerlink" title="2.1.编辑按钮点击事件"></a>2.1.编辑按钮点击事件</h2><p>在商品详情页，每一个商品后面，都会有一个编辑按钮：</p>
<p><img src="assets/1528476387213.png" alt="1528476387213"></p>
<p>点击这个按钮，就会打开一个商品编辑窗口，我们看下它所绑定的点击事件：</p>
<p><img src="assets/1528476530008.png" alt="1528476530008"></p>
<p>对应的方法：</p>
<p><img src="assets/1528476579123.png" alt="1528476579123"></p>
<p>可以看到这里发起了两个请求，在查询商品详情和sku信息。</p>
<p>因为在商品列表页面，只有spu的基本信息：id、标题、品牌、商品分类等。比较复杂的商品详情（spuDetail)和sku信息都没有，编辑页面要回显数据，就需要查询这些内容。</p>
<p>因此，接下来我们就编写后台接口，提供查询服务接口。</p>
<h2 id="2-2-查询SpuDetail接口"><a href="#2-2-查询SpuDetail接口" class="headerlink" title="2.2.查询SpuDetail接口"></a>2.2.查询SpuDetail接口</h2><blockquote>
<p>GoodsController</p>
</blockquote>
<p>需要分析的内容：</p>
<ul>
<li>请求方式：GET</li>
<li>请求路径：/spu/detail/{id}</li>
<li>请求参数：id，应该是spu的id</li>
<li>返回结果：SpuDetail对象</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@GetMapping(&quot;/spu/detail/&#123;id&#125;&quot;)</span></span><br><span class="line"><span class="function"><span class="keyword">public</span> ResponseEntity&lt;SpuDetail&gt; <span class="title">querySpuDetailById</span><span class="params">(<span class="meta">@PathVariable(&quot;id&quot;)</span> Long id)</span> </span>&#123;</span><br><span class="line">    SpuDetail detail = <span class="keyword">this</span>.goodsService.querySpuDetailById(id);</span><br><span class="line">    <span class="keyword">if</span> (detail == <span class="keyword">null</span>) &#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="keyword">new</span> ResponseEntity&lt;&gt;(HttpStatus.NOT_FOUND);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> ResponseEntity.ok(detail);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<blockquote>
<p>GoodsService</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">public</span> SpuDetail <span class="title">querySpuDetailById</span><span class="params">(Long id)</span> </span>&#123;</span><br><span class="line">    <span class="keyword">return</span> <span class="keyword">this</span>.spuDetailMapper.selectByPrimaryKey(id);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<blockquote>
<p>测试</p>
</blockquote>
<p><img src="assets/1528477123640.png" alt="1528477123640"></p>
<h2 id="2-3-查询sku"><a href="#2-3-查询sku" class="headerlink" title="2.3.查询sku"></a>2.3.查询sku</h2><blockquote>
<p>分析</p>
</blockquote>
<ul>
<li>请求方式：Get</li>
<li>请求路径：/sku/list</li>
<li>请求参数：id，应该是spu的id</li>
<li>返回结果：sku的集合</li>
</ul>
<blockquote>
<p>GoodsController</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@GetMapping(&quot;sku/list&quot;)</span></span><br><span class="line"><span class="keyword">public</span> ResponseEntity&lt;List&lt;Sku&gt;&gt; querySkuBySpuId(<span class="meta">@RequestParam(&quot;id&quot;)</span> Long id) &#123;</span><br><span class="line">    List&lt;Sku&gt; skus = <span class="keyword">this</span>.goodsService.querySkuBySpuId(id);</span><br><span class="line">    <span class="keyword">if</span> (skus == <span class="keyword">null</span> || skus.size() == <span class="number">0</span>) &#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="keyword">new</span> ResponseEntity&lt;&gt;(HttpStatus.NOT_FOUND);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> ResponseEntity.ok(skus);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>



<blockquote>
<p>GoodsService</p>
</blockquote>
<p>需要注意的是，为了页面回显方便，我们一并把sku的库存stock也查询出来</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">public</span> List&lt;Sku&gt; <span class="title">querySkuBySpuId</span><span class="params">(Long spuId)</span> </span>&#123;</span><br><span class="line">    <span class="comment">// 查询sku</span></span><br><span class="line">    Sku record = <span class="keyword">new</span> Sku();</span><br><span class="line">    record.setSpuId(spuId);</span><br><span class="line">    List&lt;Sku&gt; skus = <span class="keyword">this</span>.skuMapper.select(record);</span><br><span class="line">    <span class="keyword">for</span> (Sku sku : skus) &#123;</span><br><span class="line">        <span class="comment">// 同时查询出库存</span></span><br><span class="line">        sku.setStock(<span class="keyword">this</span>.stockMapper.selectByPrimaryKey(sku.getId()).getStock());</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> skus;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<blockquote>
<p>测试：</p>
</blockquote>
<p><img src="assets/1528477189379.png" alt="1528477189379"></p>
<h2 id="2-4-页面回显"><a href="#2-4-页面回显" class="headerlink" title="2.4.页面回显"></a>2.4.页面回显</h2><p>随便点击一个编辑按钮，发现数据回显完成：</p>
<p><img src="assets/1528477890801.png" alt="1528477890801"></p>
<p><img src="assets/1528477928748.png" alt="1528477928748"></p>
<p><img src="assets/1528477970912.png" alt="1528477970912"></p>
<p><img src="assets/1528478019100.png" alt="1528478019100"></p>
<h2 id="2-5-页面提交"><a href="#2-5-页面提交" class="headerlink" title="2.5.页面提交"></a>2.5.页面提交</h2><p>这里的保存按钮与新增其实是同一个，因此提交的逻辑也是一样的，这里不再赘述。</p>
<p>随便修改点数据，然后点击保存，可以看到浏览器已经发出请求：</p>
<p><img src="assets/1528478194128.png" alt="1528478194128"></p>
<h2 id="2-6-后台实现"><a href="#2-6-后台实现" class="headerlink" title="2.6.后台实现"></a>2.6.后台实现</h2><p>接下来，我们编写后台，实现修改商品接口。</p>
<h3 id="2-6-1-Controller"><a href="#2-6-1-Controller" class="headerlink" title="2.6.1.Controller"></a>2.6.1.Controller</h3><ul>
<li>请求方式：PUT</li>
<li>请求路径：/</li>
<li>请求参数：Spu对象</li>
<li>返回结果：无</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 新增商品</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> spu</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@return</span></span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="meta">@PutMapping</span></span><br><span class="line"><span class="function"><span class="keyword">public</span> ResponseEntity&lt;Void&gt; <span class="title">updateGoods</span><span class="params">(<span class="meta">@RequestBody</span> SpuBo spu)</span> </span>&#123;</span><br><span class="line">    <span class="keyword">try</span> &#123;</span><br><span class="line">        <span class="keyword">this</span>.goodsService.update(spu);</span><br><span class="line">        <span class="keyword">return</span> <span class="keyword">new</span> ResponseEntity&lt;&gt;(HttpStatus.NO_CONTENT);</span><br><span class="line">    &#125; <span class="keyword">catch</span> (Exception e) &#123;</span><br><span class="line">        e.printStackTrace();</span><br><span class="line">        <span class="keyword">return</span> <span class="keyword">new</span> ResponseEntity&lt;&gt;(HttpStatus.INTERNAL_SERVER_ERROR);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>



<h3 id="2-6-2-Service"><a href="#2-6-2-Service" class="headerlink" title="2.6.2.Service"></a>2.6.2.Service</h3><p>spu数据可以修改，但是SKU数据无法修改，因为有可能之前存在的SKU现在已经不存在了，或者以前的sku属性都不存在了。比如以前内存有4G，现在没了。</p>
<p>因此这里直接删除以前的SKU，然后新增即可。</p>
<p>代码：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@Transactional</span></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">update</span><span class="params">(SpuBo spu)</span> </span>&#123;</span><br><span class="line">    <span class="comment">// 查询以前sku</span></span><br><span class="line">    List&lt;Sku&gt; skus = <span class="keyword">this</span>.querySkuBySpuId(spu.getId());</span><br><span class="line">    <span class="comment">// 如果以前存在，则删除</span></span><br><span class="line">    <span class="keyword">if</span>(!CollectionUtils.isEmpty(skus)) &#123;</span><br><span class="line">        List&lt;Long&gt; ids = skus.stream().map(s -&gt; s.getId()).collect(Collectors.toList());</span><br><span class="line">        <span class="comment">// 删除以前库存</span></span><br><span class="line">        Example example = <span class="keyword">new</span> Example(Stock.class);</span><br><span class="line">        example.createCriteria().andIn(<span class="string">&quot;skuId&quot;</span>, ids);</span><br><span class="line">        <span class="keyword">this</span>.stockMapper.deleteByExample(example);</span><br><span class="line"></span><br><span class="line">        <span class="comment">// 删除以前的sku</span></span><br><span class="line">        Sku record = <span class="keyword">new</span> Sku();</span><br><span class="line">        record.setSpuId(spu.getId());</span><br><span class="line">        <span class="keyword">this</span>.skuMapper.delete(record);</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">// 新增sku和库存</span></span><br><span class="line">    saveSkuAndStock(spu.getSkus(), spu.getId());</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 更新spu</span></span><br><span class="line">    spu.setLastUpdateTime(<span class="keyword">new</span> Date());</span><br><span class="line">    spu.setCreateTime(<span class="keyword">null</span>);</span><br><span class="line">    spu.setValid(<span class="keyword">null</span>);</span><br><span class="line">    spu.setSaleable(<span class="keyword">null</span>);</span><br><span class="line">    <span class="keyword">this</span>.spuMapper.updateByPrimaryKeySelective(spu);</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 更新spu详情</span></span><br><span class="line">    <span class="keyword">this</span>.spuDetailMapper.updateByPrimaryKeySelective(spu.getSpuDetail());</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>



<h3 id="2-6-3-mapper"><a href="#2-6-3-mapper" class="headerlink" title="2.6.3.mapper"></a>2.6.3.mapper</h3><p>与以前一样。</p>
<h2 id="2-7-其它"><a href="#2-7-其它" class="headerlink" title="2.7.其它"></a>2.7.其它</h2><p>商品的删除、上下架大家自行实现。</p>
<h1 id="3-搭建前台系统"><a href="#3-搭建前台系统" class="headerlink" title="3.搭建前台系统"></a>3.搭建前台系统</h1><p>后台系统的内容暂时告一段落，有了商品，接下来我们就要在页面展示商品，给用户提供浏览和购买的入口，那就是我们的门户系统。</p>
<p>门户系统面向的是用户，安全性很重要，而且搜索引擎对于单页应用并不友好。因此我们的门户系统不再采用与后台系统类似的SPA（单页应用）。</p>
<p>依然是前后端分离，不过前端的页面会使用独立的html，在每个页面中使用vue来做页面渲染。</p>
<h2 id="3-1-静态资源"><a href="#3-1-静态资源" class="headerlink" title="3.1.静态资源"></a>3.1.静态资源</h2><p>webpack打包多页应用配置比较繁琐，项目结构也相对复杂。这里为了简化开发（毕竟我们不是专业的前端人员），我们不再使用webpack，而是直接编写原生的静态HTML。</p>
<h3 id="3-1-1-创建工程"><a href="#3-1-1-创建工程" class="headerlink" title="3.1.1.创建工程"></a>3.1.1.创建工程</h3><p>创建一个新的工程：</p>
<p><img src="assets/1528479807646.png" alt="1528479807646"></p>
<p><img src="assets/1528479863567.png" alt="1528479863567"></p>
<h3 id="3-1-2-导入静态资源"><a href="#3-1-2-导入静态资源" class="headerlink" title="3.1.2.导入静态资源"></a>3.1.2.导入静态资源</h3><p>将课前资料中的leyou-portal解压，并复制到这个项目下</p>
<p><img src="assets/1528479930705.png" alt="1528479930705"></p>
<p>解压缩：</p>
<p><img src="assets/1528479984188.png" alt="1528479984188"></p>
<p>项目结构：</p>
<p> <img src="assets/1528480139441.png" alt="1528480139441"></p>
<h2 id="3-2-live-server"><a href="#3-2-live-server" class="headerlink" title="3.2.live-server"></a>3.2.live-server</h2><p>没有webpack，我们就无法使用webpack-dev-server运行这个项目，实现热部署。</p>
<p>所以，这里我们使用另外一种热部署方式：live-server，</p>
<h3 id="3-2-1-简介"><a href="#3-2-1-简介" class="headerlink" title="3.2.1.简介"></a>3.2.1.简介</h3><p>地址；<a target="_blank" rel="noopener" href="https://www.npmjs.com/package/live-server">https://www.npmjs.com/package/live-server</a></p>
<p> <img src="assets/1526460917348.png" alt="1526460917348"></p>
<p>这是一款带有热加载功能的小型开发服务器。用它来展示你的HTML / JavaScript / CSS，但不能用于部署最终的网站。 </p>
<h3 id="3-2-2-安装和运行参数"><a href="#3-2-2-安装和运行参数" class="headerlink" title="3.2.2.安装和运行参数"></a>3.2.2.安装和运行参数</h3><p>安装，使用npm命令即可，这里建议全局安装，以后任意位置可用</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm install -g live-server</span><br></pre></td></tr></table></figure>



<p>运行时，直接输入命令：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">live-server</span><br></pre></td></tr></table></figure>

<p>另外，你可以在运行命令后，跟上一些参数以配置：</p>
<ul>
<li><code>--port=NUMBER</code> - 选择要使用的端口，默认值：PORT env var或8080</li>
<li><code>--host=ADDRESS</code> - 选择要绑定的主机地址，默认值：IP env var或0.0.0.0（“任意地址”）</li>
<li><code>--no-browser</code> - 禁止自动Web浏览器启动</li>
<li><code>--browser=BROWSER</code> - 指定使用浏览器而不是系统默认值</li>
<li><code>--quiet | -q</code> - 禁止记录</li>
<li><code>--verbose | -V</code> - 更多日志记录（记录所有请求，显示所有侦听的IPv4接口等）</li>
<li><code>--open=PATH</code> - 启动浏览器到PATH而不是服务器root</li>
<li><code>--watch=PATH</code> - 用逗号分隔的路径来专门监视变化（默认值：观看所有内容）</li>
<li><code>--ignore=PATH</code>- 要忽略的逗号分隔的路径字符串（<a target="_blank" rel="noopener" href="https://github.com/es128/anymatch">anymatch</a> -compatible definition）</li>
<li><code>--ignorePattern=RGXP</code>-文件的正则表达式忽略（即<code>.*\.jade</code>）（<strong>不推荐使用</strong>赞成<code>--ignore</code>）</li>
<li><code>--middleware=PATH</code> - 导出要添加的中间件功能的.js文件的路径; 可以是没有路径的名称，也可以是引用<code>middleware</code>文件夹中捆绑的中间件的扩展名</li>
<li><code>--entry-file=PATH</code> - 提供此文件（服务器根目录）代替丢失的文件（对单页应用程序有用）</li>
<li><code>--mount=ROUTE:PATH</code> - 在定义的路线下提供路径内容（可能有多个定义）</li>
<li><code>--spa</code> - 将请求从/ abc转换为/＃/ abc（方便单页应用）</li>
<li><code>--wait=MILLISECONDS</code> - （默认100ms）等待所有更改，然后重新加载</li>
<li><code>--htpasswd=PATH</code> - 启用期待位于PATH的htpasswd文件的http-auth</li>
<li><code>--cors</code> - 为任何来源启用CORS（反映请求源，支持凭证的请求）</li>
<li><code>--https=PATH</code> - 到HTTPS配置模块的路径</li>
<li><code>--proxy=ROUTE:URL</code> - 代理ROUTE到URL的所有请求</li>
<li><code>--help | -h</code> - 显示简洁的使用提示并退出</li>
<li><code>--version | -v</code> - 显示版本并退出</li>
</ul>
<h3 id="3-2-3-测试"><a href="#3-2-3-测试" class="headerlink" title="3.2.3.测试"></a>3.2.3.测试</h3><p>我们进入leyou-portal目录，输入命令：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">live-server --port&#x3D;9002</span><br></pre></td></tr></table></figure>

<p><img src="assets/1528480541193.png" alt="1528480541193"></p>
<h2 id="3-3-域名访问"><a href="#3-3-域名访问" class="headerlink" title="3.3.域名访问"></a>3.3.域名访问</h2><p>现在我们访问只能通过：<a target="_blank" rel="noopener" href="http://127.0.0.1:9002/">http://127.0.0.1:9002</a></p>
<p>我们希望用域名访问：<a target="_blank" rel="noopener" href="http://www.leyou.com/">http://www.leyou.com</a></p>
<p>第一步，修改hosts文件，添加一行配置：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">127.0.0.1 www.leyou.com</span><br></pre></td></tr></table></figure>

<p>第二步，修改nginx配置，将<a target="_blank" rel="noopener" href="http://www.leyou.com反向代理到127.0.0.1:9002/">www.leyou.com反向代理到127.0.0.1:9002</a></p>
<figure class="highlight nginx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="section">server</span> &#123;</span><br><span class="line">    <span class="attribute">listen</span>       <span class="number">80</span>;</span><br><span class="line">    <span class="attribute">server_name</span>  www.leyou.com;</span><br><span class="line"></span><br><span class="line">    <span class="attribute">proxy_set_header</span> X-Forwarded-Host <span class="variable">$host</span>;</span><br><span class="line">    <span class="attribute">proxy_set_header</span> X-Forwarded-Server <span class="variable">$host</span>;</span><br><span class="line">    <span class="attribute">proxy_set_header</span> X-Forwarded-For <span class="variable">$proxy_add_x_forwarded_for</span>;</span><br><span class="line"></span><br><span class="line">    <span class="attribute">location</span> / &#123;</span><br><span class="line">        <span class="attribute">proxy_pass</span> http://127.0.0.1:9002;</span><br><span class="line">        <span class="attribute">proxy_connect_timeout</span> <span class="number">600</span>;</span><br><span class="line">        <span class="attribute">proxy_read_timeout</span> <span class="number">600</span>;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>重新加载nginx配置：<code>nginx.exe -s reload</code></p>
<p><img src="assets/1526462774092.png" alt="1526462774092"></p>
<h2 id="3-4-common-js"><a href="#3-4-common-js" class="headerlink" title="3.4.common.js"></a>3.4.common.js</h2><p>为了方便后续的开发，我们在前台系统中定义了一些工具，放在了common.js中：</p>
<p> <img src="assets/1526643361038.png" alt="1526643361038"></p>
<p>部分代码截图：</p>
<p> <img src="H:/%E4%B9%90%E4%BC%98/7%E6%9C%881%E5%8F%B7%E6%9B%B4%E6%96%B0/day10-%E5%95%86%E5%93%81%E7%AE%A1%E7%90%86/assets/1526643526973.png" alt="1526643526973"></p>
<p>首先对axios进行了一些全局配置，请求超时时间，请求的基础路径，是否允许跨域操作cookie等</p>
<p>定义了对象 ly ，也叫leyou，包含了下面的属性：</p>
<ul>
<li>getUrlParam(key)：获取url路径中的参数</li>
<li>http：axios对象的别名。以后发起ajax请求，可以用ly.http.get()</li>
<li>store：localstorage便捷操作，后面用到再详细说明</li>
<li>formatPrice：格式化价格，如果传入的是字符串，则扩大100被并转为数字，如果传入是数字，则缩小100倍并转为字符串</li>
<li>formatDate(val, pattern)：对日期对象val按照指定的pattern模板进行格式化</li>
<li>stringify：将对象转为参数字符串</li>
<li>parse：将参数字符串变为js对象</li>
</ul>

            </div>
            <hr/>

            

    <div class="reprint" id="reprint-statement">
        
            <div class="reprint__author">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-user">
                        Author:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="/about" rel="external nofollow noreferrer">AverageJoe</a>
                </span>
            </div>
            <div class="reprint__type">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-link">
                        Link:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="http://www.averagejoe.top/2018/10/08/leyou/day10-bi-ji/day10-shang-pin-guan-li/">http://www.averagejoe.top/2018/10/08/leyou/day10-bi-ji/day10-shang-pin-guan-li/</a>
                </span>
            </div>
            <div class="reprint__notice">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-copyright">
                        Reprint policy:
                    </i>
                </span>
                <span class="reprint-info">
                    All articles in this blog are used except for special statements
                    <a href="https://creativecommons.org/licenses/by/4.0/deed.zh" rel="external nofollow noreferrer" target="_blank">CC BY 4.0</a>
                    reprint polocy. If reproduced, please indicate source
                    <a href="/about" target="_blank">AverageJoe</a>
                    !
                </span>
            </div>
        
    </div>

    <script async defer>
      document.addEventListener("copy", function (e) {
        let toastHTML = '<span>Copied successfully, please follow the reprint policy of this article</span><button class="btn-flat toast-action" onclick="navToReprintStatement()" style="font-size: smaller">more</a>';
        M.toast({html: toastHTML})
      });

      function navToReprintStatement() {
        $("html, body").animate({scrollTop: $("#reprint-statement").offset().top - 80}, 800);
      }
    </script>



            <div class="tag_share" style="display: block;">
                <div class="post-meta__tag-list" style="display: inline-block;">
                    
                        <div class="article-tag">
                            <span class="chip bg-color">No tag</span>
                        </div>
                    
                </div>
                <div class="post_share" style="zoom: 80%; width: fit-content; display: inline-block; float: right; margin: -0.15rem 0;">
                    <link rel="stylesheet" type="text/css" href="/libs/share/css/share.min.css">
<div id="article-share">

    
    <div class="social-share" data-sites="twitter,facebook,google,qq,qzone,wechat,weibo,douban,linkedin" data-wechat-qrcode-helper="<p>微信扫一扫即可分享！</p>"></div>
    <script src="/libs/share/js/social-share.min.js"></script>
    

    

</div>

                </div>
            </div>
            
                <style>
    #reward {
        margin: 40px 0;
        text-align: center;
    }

    #reward .reward-link {
        font-size: 1.4rem;
        line-height: 38px;
    }

    #reward .btn-floating:hover {
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.2);
    }

    #rewardModal {
        width: 320px;
        height: 350px;
    }

    #rewardModal .reward-title {
        margin: 15px auto;
        padding-bottom: 5px;
    }

    #rewardModal .modal-content {
        padding: 10px;
    }

    #rewardModal .close {
        position: absolute;
        right: 15px;
        top: 15px;
        color: rgba(0, 0, 0, 0.5);
        font-size: 1.3rem;
        line-height: 20px;
        cursor: pointer;
    }

    #rewardModal .close:hover {
        color: #ef5350;
        transform: scale(1.3);
        -moz-transform:scale(1.3);
        -webkit-transform:scale(1.3);
        -o-transform:scale(1.3);
    }

    #rewardModal .reward-tabs {
        margin: 0 auto;
        width: 210px;
    }

    .reward-tabs .tabs {
        height: 38px;
        margin: 10px auto;
        padding-left: 0;
    }

    .reward-content ul {
        padding-left: 0 !important;
    }

    .reward-tabs .tabs .tab {
        height: 38px;
        line-height: 38px;
    }

    .reward-tabs .tab a {
        color: #fff;
        background-color: #ccc;
    }

    .reward-tabs .tab a:hover {
        background-color: #ccc;
        color: #fff;
    }

    .reward-tabs .wechat-tab .active {
        color: #fff !important;
        background-color: #22AB38 !important;
    }

    .reward-tabs .alipay-tab .active {
        color: #fff !important;
        background-color: #019FE8 !important;
    }

    .reward-tabs .reward-img {
        width: 210px;
        height: 210px;
    }
</style>

<div id="reward">
    <a href="#rewardModal" class="reward-link modal-trigger btn-floating btn-medium waves-effect waves-light red">赏</a>

    <!-- Modal Structure -->
    <div id="rewardModal" class="modal">
        <div class="modal-content">
            <a class="close modal-close"><i class="fas fa-times"></i></a>
            <h4 class="reward-title">你的赏识是我前进的动力</h4>
            <div class="reward-content">
                <div class="reward-tabs">
                    <ul class="tabs row">
                        <li class="tab col s6 alipay-tab waves-effect waves-light"><a href="#alipay">支付宝</a></li>
                        <li class="tab col s6 wechat-tab waves-effect waves-light"><a href="#wechat">微 信</a></li>
                    </ul>
                    <div id="alipay">
                        <img src="/medias/reward/alipay.jpg" class="reward-img" alt="支付宝打赏二维码">
                    </div>
                    <div id="wechat">
                        <img src="/medias/reward/wechat.png" class="reward-img" alt="微信打赏二维码">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        $('.tabs').tabs();
    });
</script>

            
        </div>
    </div>

    

    

    

    

    
        <style>
    .valine-card {
        margin: 1.5rem auto;
    }

    .valine-card .card-content {
        padding: 20px 20px 5px 20px;
    }

    #vcomments textarea {
        box-sizing: border-box;
        background: url("/medias/comment_bg.png") 100% 100% no-repeat;
    }

    #vcomments p {
        margin: 2px 2px 10px;
        font-size: 1.05rem;
        line-height: 1.78rem;
    }

    #vcomments blockquote p {
        text-indent: 0.2rem;
    }

    #vcomments a {
        padding: 0 2px;
        color: #4cbf30;
        font-weight: 500;
        text-decoration: none;
    }

    #vcomments img {
        max-width: 100%;
        height: auto;
        cursor: pointer;
    }

    #vcomments ol li {
        list-style-type: decimal;
    }

    #vcomments ol,
    ul {
        display: block;
        padding-left: 2em;
        word-spacing: 0.05rem;
    }

    #vcomments ul li,
    ol li {
        display: list-item;
        line-height: 1.8rem;
        font-size: 1rem;
    }

    #vcomments ul li {
        list-style-type: disc;
    }

    #vcomments ul ul li {
        list-style-type: circle;
    }

    #vcomments table, th, td {
        padding: 12px 13px;
        border: 1px solid #dfe2e5;
    }

    #vcomments table, th, td {
        border: 0;
    }

    table tr:nth-child(2n), thead {
        background-color: #fafafa;
    }

    #vcomments table th {
        background-color: #f2f2f2;
        min-width: 80px;
    }

    #vcomments table td {
        min-width: 80px;
    }

    #vcomments h1 {
        font-size: 1.85rem;
        font-weight: bold;
        line-height: 2.2rem;
    }

    #vcomments h2 {
        font-size: 1.65rem;
        font-weight: bold;
        line-height: 1.9rem;
    }

    #vcomments h3 {
        font-size: 1.45rem;
        font-weight: bold;
        line-height: 1.7rem;
    }

    #vcomments h4 {
        font-size: 1.25rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    #vcomments h5 {
        font-size: 1.1rem;
        font-weight: bold;
        line-height: 1.4rem;
    }

    #vcomments h6 {
        font-size: 1rem;
        line-height: 1.3rem;
    }

    #vcomments p {
        font-size: 1rem;
        line-height: 1.5rem;
    }

    #vcomments hr {
        margin: 12px 0;
        border: 0;
        border-top: 1px solid #ccc;
    }

    #vcomments blockquote {
        margin: 15px 0;
        border-left: 5px solid #42b983;
        padding: 1rem 0.8rem 0.3rem 0.8rem;
        color: #666;
        background-color: rgba(66, 185, 131, .1);
    }

    #vcomments pre {
        font-family: monospace, monospace;
        padding: 1.2em;
        margin: .5em 0;
        background: #272822;
        overflow: auto;
        border-radius: 0.3em;
        tab-size: 4;
    }

    #vcomments code {
        font-family: monospace, monospace;
        padding: 1px 3px;
        font-size: 0.92rem;
        color: #e96900;
        background-color: #f8f8f8;
        border-radius: 2px;
    }

    #vcomments pre code {
        font-family: monospace, monospace;
        padding: 0;
        color: #e8eaf6;
        background-color: #272822;
    }

    #vcomments pre[class*="language-"] {
        padding: 1.2em;
        margin: .5em 0;
    }

    #vcomments code[class*="language-"],
    pre[class*="language-"] {
        color: #e8eaf6;
    }

    #vcomments [type="checkbox"]:not(:checked), [type="checkbox"]:checked {
        position: inherit;
        margin-left: -1.3rem;
        margin-right: 0.4rem;
        margin-top: -1px;
        vertical-align: middle;
        left: unset;
        visibility: visible;
    }

    #vcomments b,
    strong {
        font-weight: bold;
    }

    #vcomments dfn {
        font-style: italic;
    }

    #vcomments small {
        font-size: 85%;
    }

    #vcomments cite {
        font-style: normal;
    }

    #vcomments mark {
        background-color: #fcf8e3;
        padding: .2em;
    }

    #vcomments table, th, td {
        padding: 12px 13px;
        border: 1px solid #dfe2e5;
    }

    table tr:nth-child(2n), thead {
        background-color: #fafafa;
    }

    #vcomments table th {
        background-color: #f2f2f2;
        min-width: 80px;
    }

    #vcomments table td {
        min-width: 80px;
    }

    #vcomments [type="checkbox"]:not(:checked), [type="checkbox"]:checked {
        position: inherit;
        margin-left: -1.3rem;
        margin-right: 0.4rem;
        margin-top: -1px;
        vertical-align: middle;
        left: unset;
        visibility: visible;
    }
</style>

<div class="card valine-card" data-aos="fade-up">
    <div class="comment_headling" style="font-size: 20px; font-weight: 700; position: relative; padding-left: 20px; top: 15px; padding-bottom: 5px;">
        <i class="fas fa-comments fa-fw" aria-hidden="true"></i>
        <span>评论</span>
    </div>
    <div id="vcomments" class="card-content" style="display: grid">
    </div>
</div>

<script src="/libs/valine/av-min.js"></script>
<script src="/libs/valine/Valine.min.js"></script>
<script>
    new Valine({
        el: '#vcomments',
        appId: 'BhOC9gMKAfPsRTjqr679tX7A-gzGzoHsz',
        appKey: 'xb9C1I9k62m6AJvin0UWGhSr',
        notify: 'false' === 'true',
        verify: 'false' === 'true',
        visitor: 'true' === 'true',
        avatar: 'mm',
        pageSize: '10',
        lang: 'en',
        placeholder: 'just go go'
    });
</script>

    

    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge left-badge text-color">
                <i class="fas fa-chevron-left"></i>&nbsp;Previous</div>
            <div class="card">
                <a href="/2018/10/11/leyou/day11-bi-ji/day11-elasticsearch/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/0.jpg" class="responsive-img" alt="">
                        
                        <span class="card-title"></span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            0.学习目标
独立安装Elasticsearch
会使用Rest的API操作索引
会使用Rest的API查询数据
会使用Rest的API聚合数据
掌握Spring Data Elasticsearch使用

1.Elasticsearch介
                        
                    </div>
                    <div class="publish-info">
                        <span class="publish-date">
                            <i class="far fa-clock fa-fw icon-date"></i>2018-10-11
                        </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-user fa-fw"></i>
                            AverageJoe
                            
                        </span>
                    </div>
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge right-badge text-color">
                Next&nbsp;<i class="fas fa-chevron-right"></i>
            </div>
            <div class="card">
                <a href="/2018/08/19/leyou/day01-bi-ji/day01-springboot/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/0.jpg" class="responsive-img" alt="">
                        
                        <span class="card-title"></span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            0.学习目标
了解SpringBoot的作用
掌握java配置的方式
了解SpringBoot自动配置原理
掌握SpringBoot的基本使用
了解Thymeleaf的基本使用

1. 了解SpringBoot在这一部分，我们主要了解以下3
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2018-08-19
                            </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-user fa-fw"></i>
                            AverageJoe
                            
                        </span>
                    </div>
                </div>
                
            </div>
        </div>
        
    </div>
</article>

</div>



<!-- 代码块功能依赖 -->
<script type="text/javascript" src="/libs/codeBlock/codeBlockFuction.js"></script>

<!-- 代码语言 -->

<script type="text/javascript" src="/libs/codeBlock/codeLang.js"></script>


<!-- 代码块复制 -->

<script type="text/javascript" src="/libs/codeBlock/codeCopy.js"></script>


<!-- 代码块收缩 -->

<script type="text/javascript" src="/libs/codeBlock/codeShrink.js"></script>


<!-- 代码块折行 -->

<style type="text/css">
code[class*="language-"], pre[class*="language-"] { white-space: pre !important; }
</style>


    </div>
    <div id="toc-aside" class="expanded col l3 hide-on-med-and-down">
        <div class="toc-widget">
            <div class="toc-title"><i class="far fa-list-alt"></i>&nbsp;&nbsp;TOC</div>
            <div id="toc-content"></div>
        </div>
    </div>
</div>

<!-- TOC 悬浮按钮. -->

<div id="floating-toc-btn" class="hide-on-med-and-down">
    <a class="btn-floating btn-large bg-color">
        <i class="fas fa-list-ul"></i>
    </a>
</div>


<script src="/libs/tocbot/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingsOffset: -($(window).height() * 0.4 - 45),
            collapseDepth: Number('0'),
            headingSelector: 'h2, h3, h4'
        });

        // modify the toc link href to support Chinese.
        let i = 0;
        let tocHeading = 'toc-heading-';
        $('#toc-content a').each(function () {
            $(this).attr('href', '#' + tocHeading + (++i));
        });

        // modify the heading title id to support Chinese.
        i = 0;
        $('#articleContent').children('h2, h3, h4').each(function () {
            $(this).attr('id', tocHeading + (++i));
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });

        
        /* 修复文章卡片 div 的宽度. */
        let fixPostCardWidth = function (srcId, targetId) {
            let srcDiv = $('#' + srcId);
            if (srcDiv.length === 0) {
                return;
            }

            let w = srcDiv.width();
            if (w >= 450) {
                w = w + 21;
            } else if (w >= 350 && w < 450) {
                w = w + 18;
            } else if (w >= 300 && w < 350) {
                w = w + 16;
            } else {
                w = w + 14;
            }
            $('#' + targetId).width(w);
        };

        // 切换TOC目录展开收缩的相关操作.
        const expandedClass = 'expanded';
        let $tocAside = $('#toc-aside');
        let $mainContent = $('#main-content');
        $('#floating-toc-btn .btn-floating').click(function () {
            if ($tocAside.hasClass(expandedClass)) {
                $tocAside.removeClass(expandedClass).hide();
                $mainContent.removeClass('l9');
            } else {
                $tocAside.addClass(expandedClass).show();
                $mainContent.addClass('l9');
            }
            fixPostCardWidth('artDetail', 'prenext-posts');
        });
        
    });
</script>

    

</main>




    <footer class="page-footer bg-color">
    
        <link rel="stylesheet" href="/libs/aplayer/APlayer.min.css">
<style>
    .aplayer .aplayer-lrc p {
        
        display: none;
        
        font-size: 12px;
        font-weight: 700;
        line-height: 16px !important;
    }

    .aplayer .aplayer-lrc p.aplayer-lrc-current {
        
        display: none;
        
        font-size: 15px;
        color: #42b983;
    }

    
    .aplayer.aplayer-fixed.aplayer-narrow .aplayer-body {
        left: -66px !important;
    }

    .aplayer.aplayer-fixed.aplayer-narrow .aplayer-body:hover {
        left: 0px !important;
    }

    
</style>
<div class="">
    
    <div class="row">
        <meting-js class="col l8 offset-l2 m10 offset-m1 s12"
                   server="netease"
                   type="playlist"
                   id="503838841"
                   fixed='true'
                   autoplay='false'
                   theme='#42b983'
                   loop='all'
                   order='random'
                   preload='auto'
                   volume='0.7'
                   list-folded='true'
        >
        </meting-js>
    </div>
</div>

<script src="/libs/aplayer/APlayer.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/meting@2/dist/Meting.min.js"></script>

    
    <div class="container row center-align" style="margin-bottom: 0px !important;">
        <div class="col s12 m8 l8 copy-right">
            Copyright&nbsp;&copy;
            <span id="year">2019</span>
            <a href="/about" target="_blank">AverageJoe</a>
            |&nbsp;Powered by&nbsp;<a href="#" target="_blank">AverageJoe</a>
            |&nbsp;Theme&nbsp;<a href="#" target="_blank">Matery</a>
            <br>
            
            &nbsp;<i class="fas fa-chart-area"></i>&nbsp;站点总字数:&nbsp;<span
                class="white-color">213.1k</span>&nbsp;字
            
            
            
            
            
            
            <span id="busuanzi_container_site_pv">
                |&nbsp;<i class="far fa-eye"></i>&nbsp;总访问量:&nbsp;<span id="busuanzi_value_site_pv"
                    class="white-color"></span>&nbsp;次
            </span>
            
            
            <span id="busuanzi_container_site_uv">
                |&nbsp;<i class="fas fa-users"></i>&nbsp;总访问人数:&nbsp;<span id="busuanzi_value_site_uv"
                    class="white-color"></span>&nbsp;人
            </span>
            
            <br>
            
            <br>
            
        </div>
        <div class="col s12 m4 l4 social-link social-statis">


    <a href="mailto:1533360044@qq.com" class="tooltipped" target="_blank" data-tooltip="邮件联系我" data-position="top" data-delay="50">
        <i class="fas fa-envelope-open"></i>
    </a>







    <a href="tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin=1533360044" class="tooltipped" target="_blank" data-tooltip="QQ联系我: 1533360044" data-position="top" data-delay="50">
        <i class="fab fa-qq"></i>
    </a>







    <a href="/atom.xml" class="tooltipped" target="_blank" data-tooltip="RSS 订阅" data-position="top" data-delay="50">
        <i class="fas fa-rss"></i>
    </a>

</div>
    </div>
</footer>

<div class="progress-bar"></div>


    <!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title"><i class="fas fa-search"></i>&nbsp;&nbsp;Search</span>
            <input type="search" id="searchInput" name="s" placeholder="Please enter a search keyword"
                   class="search-input">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script src="/js/search.js"></script>
<script type="text/javascript">
$(function () {
    searchFunc("/search.xml", 'searchInput', 'searchResult');
});
</script>

    <!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fas fa-arrow-up"></i>
    </a>
</div>


    <script src="/libs/materialize/materialize.min.js"></script>
    <script src="/libs/masonry/masonry.pkgd.min.js"></script>
    <script src="/libs/aos/aos.js"></script>
    <script src="/libs/scrollprogress/scrollProgress.min.js"></script>
    <script src="/libs/lightGallery/js/lightgallery-all.min.js"></script>
    <script src="/js/matery.js"></script>

    <!-- Baidu Analytics -->

    <!-- Baidu Push -->

<script>
    (function () {
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        } else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
</script>

    
    <script src="/libs/others/clicklove.js" async="async"></script>
    
    
    <script async src="/libs/others/busuanzi.pure.mini.js"></script>
    

    

    

    

    

    

    
    <script src="/libs/instantpage/instantpage.js" type="module"></script>
    
	

	<div id="weather-v2-plugin-simple"></div>
<script>
WIDGET = {
  CONFIG: {
    "modules": "0124",
    "background": 1,
    "tmpColor": "FFFFFF",
    "tmpSize": 16,
    "cityColor": "FFFFFF",
    "citySize": 16,
    "aqiSize": 16,
    "weatherIconSize": 24,
    "alertIconSize": 18,
    "padding": "10px 10px 10px 10px",
    "shadow": "1",
    "language": "auto",
    "borderRadius": 5,
    "fixed": "false",
    "vertical": "middle",
    "horizontal": "center",
    "key": "XZgo8dbNqo"
  }
}
</script>
<script src="https://apip.weatherdt.com/simple/static/js/weather-simple-common.js?v=2.0"></script>
<script src="/js/cursor.js"></script>
</body>

</html>
